﻿<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>密码修改</title>
    <link rel="stylesheet" type="text/css" href="Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="Content/Css/home.css" />
    <link rel="stylesheet" type="text/css" href="Content/Css/list.css" />
    <script type="text/javascript" src="Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="Scripts/json2.js"></script>
    <script type="text/javascript" src="Scripts/common.js"></script>
    <script type="text/javascript" src="Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <script type="text/javascript" src="Scripts/banBackSpace.js"></script>
    <script type="text/javascript">
        var validatorForm, currentUID;

        $(document).ready(function () {
            currentUID = art.dialog.data('currentUID');
            validatorForm = $('#viewForm').validate({
                errorContainer: "#errorMessages",
                errorLabelContainer: "#errorMessages",
                wrapper: "span",
                errorClass: "omError",
                rules: {
                    OldPWD: { required: true },
                    NewPWD: { required: true, minlength: 4 },
                    ConfirmPWD: { required: true, minlength: 4, equalTo: $('#NewPWD') }
                },
                messages: {
                    OldPWD: { required: "[旧密码]不能为空" },
                    NewPWD: { required: "[新密码]不能为空", minlength: "长度至少为4" },
                    ConfirmPWD: { required: "[确认密码]不能为空", minlength: "长度至少为4", equalTo: "和新密码不一致" }
                }
            });
            $("#UserID").val(currentUID);
            $("#UserID").attr("disabled", true);
            $('span#button-save').omButton({
                icons: { left: 'Content/Images/List/accept.png' }, width: 80,
                onClick: function () {
                    if (validatorForm.form()) {
                        $.ajax({
                            cache: false, async: false,
                            url: 'handler/ajax.ashx?type=AjaxSystem&method=ChangePWD',
                            dataType: 'json', type: 'post',
                            data: { USERID: currentUID, OLDPWD: $("#OldPWD").val(), NEWPWD: $("#NewPWD").val() },
                            beforeSend: function () {
                                $.omMessageBox.waiting({
                                    title: '请等待',
                                    content: '系统正在提交信息,请稍后...'
                                });
                            },
                            complete: function () {
                                $.omMessageBox.waiting("close");
                            },
                            success: function (data) {
                                if (data.IsError) {
                                    $.omMessageBox.alert({
                                        content: '错误：' + data.Message
                                    });
                                }
                                else {
                                    $.omMessageBox.alert({
                                        content: '密码修改成功',
                                        onClose: function () {
                                            art.dialog.close();
                                        }
                                    });
                                }
                            },
                            error: function (result) {
                                $.omMessageBox.alert({
                                    content: '发现系统错误,请重新登录<BR>错误码：' + result.status
                                });
                            }
                        });
                    }
                }
            });
            $('span#button-cancel').omButton({
                icons: { left: 'Content/Images/List/cross.png' }, width: 80,
                onClick: function () {
                    art.dialog.close();
                }
            });
        });
    </script>
</head>
<body>
    <div id="detail-form">
        <form id="viewForm">
            <div id="errorMessages" class="error"></div>
            <table style="width: 100%;">
                <tr>
                    <td align="right" style="width: 80px;">用户名称</td>
                    <td align="left" style="width: 150px">
                        <input type="text" class="input-text" name="UserID" id="UserID" /></td>
                    <td align="center" style="width: 80px;"><span id="button-save">保存</span></td>
                </tr>
                <tr>
                    <td align="right" style="width: 80px; margin-left: 10px; ">旧 密 码</td>
                    <td align="left" style="width: 150px">
                        <input type="password" class="input-text" name="OldPWD" id="OldPWD" />
                    </td>
                    <td align="center" style="width: 80px;"><span id="button-cancel">取消</span></td>
                </tr>
                <tr>
                    <td align="right" style="width: 80px; margin-left: 10px; ">新 密 码</td>
                    <td align="left" style="width: 150px">
                        <input type="password" class="input-text" name="NewPWD" id="NewPWD" /></td>
                    <td align="right" style="width: 50px;"></td>
                </tr>
                <tr>
                    <td align="right" style="width: 80px;">确认密码</td>
                    <td align="left" style="width: 150px">
                        <input type="password" class="input-text" name="ConfirmPWD" id="ConfirmPWD" /></td>
                    <td align="right" style="width: 50px;"></td>
                </tr>
            </table>
        </form>
    </div>
</body>
</html>
